#ifndef __DRV_SPI_H
#define __DRV_SPI_H

#ifdef __cplusplus
 extern "C" {
#endif
#include <stm32f1xx.h>	 
#include "stdint.h"
#include "ptdef.h" 
#include "spi.h"  
#include "ptdebug.h"  
#include "device.h"  
	 
#define SPI1_BUS_CONFIG { .Instance = SPI1, .device_id = DEVIEC_ID_SPI_BUS_1 }	 

struct stm32_hw_spi_cs
{
    GPIO_TypeDef* GPIOx;
    uint16_t GPIO_Pin;
};	

struct stm32_spi_config
{
    SPI_TypeDef *Instance;
	uint8_t device_id;
//    char *bus_name;
};

struct stm32_spi_device
{
    uint32_t pin;
	
//    char *bus_name;
//    char *device_name;
};
	

/* stm32 spi dirver class */
struct stm32_spi
{
    SPI_HandleTypeDef handle;
    const struct stm32_spi_config *config;
    struct pt_spi_configuration *cfg;
    struct pt_spi_bus spi_bus;
};

int pt_hw_spi_init(void);
int32_t pt_hw_spi_device_attach(uint8_t bus_id, uint8_t dev_id, GPIO_TypeDef* cs_gpiox, uint16_t cs_gpio_pin);

#ifdef __cplusplus
}
#endif

#endif
